home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / src / priest.c < prev    next >
Encoding:
Text File  |  1993-08-01  |  17.1 KB  |  652 lines  |  [TEXT/R*ch]

  1. : didn't  -1: let m_move do it  -2: died.
  2.  */
  3. int
  4. move_special(mtmp,in_his_shop,appr,uondoor,avoid,omx,omy,gx,gy)
  5. register struct monst *mtmp;
  6. boolean in_his_shop;
  7. schar appr;
  8. boolean uondoor,avoid;
  9. register xchar omx,omy,gx,gy;
  10. {
  11.     register xchar nx,ny,nix,niy;
  12.     register schar i;
  13.     schar chcnt,cnt;
  14.     coord poss[9];
  15.     long info[9];
  16.     long allowflags;
  17.     struct obj *ib = (struct obj *)0;
  18.  
  19.     if(omx == gx && omy == gy)
  20.         return(0);
  21.     if(mtmp->mconf) {
  22.         avoid = FALSE;
  23.         appr = 0;
  24.     }
  25.  
  26.     nix = omx;
  27.     niy = omy;
  28.     if (mtmp->isshk) allowflags = ALLOW_SSM;
  29.     else allowflags = ALLOW_SSM | ALLOW_SANCT;
  30.     if (passes_walls(mtmp->data)) allowflags |= (ALLOW_ROCK|ALLOW_WALL);
  31.     if (throws_rocks(mtmp->data)) allowflags |= ALLOW_ROCK;
  32.     if (tunnels(mtmp->data) &&
  33.             (!needspick(mtmp->data) || m_carrying(mtmp, PICK_AXE)))
  34.         allowflags |= ALLOW_DIG;
  35.     if (!nohands(mtmp->data) && !verysmall(mtmp->data)) {
  36.         allowflags |= OPENDOOR;
  37.         if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= BUSTDOOR;
  38.     }
  39.     if (is_giant(mtmp->data)) allowflags |= BUSTDOOR;
  40.     cnt = mfndpos(mtmp, poss, info, allowflags);
  41.  
  42.     if(mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */
  43.         for(i=0; i<cnt; i++)
  44.             if(!(info[i] & NOTONL)) goto pick_move;
  45.         avoid = FALSE;
  46.     }
  47.  
  48. #define    GDIST(x,y)    (dist2(x,y,gx,gy))
  49. pick_move:
  50.     chcnt = 0;
  51.     for(i=0; i<cnt; i++) {
  52.         nx = poss[i].x;
  53.         ny = poss[i].y;
  54.         if(levl[nx][ny].typ == ROOM ||
  55.             (mtmp->ispriest &&
  56.                 levl[nx][ny].typ == ALTAR) ||
  57.             (mtmp->isshk &&
  58.                 (!in_his_shop || ESHK(mtmp)->following))) {
  59.             if(avoid && (info[i] & NOTONL))
  60.             continue;
  61.             if((!appr && !rn2(++chcnt)) ||
  62.             (appr && GDIST(nx,ny) < GDIST(nix,niy))) {
  63.                 nix = nx;
  64.                 niy = ny;
  65.             }
  66.         }
  67.     }
  68.     if(mtmp->ispriest && avoid &&
  69.             nix == omx && niy == omy && onlineu(omx,omy)) {
  70.         /* might as well move closer as long it's going to stay
  71.          * lined up */
  72.         avoid = FALSE;
  73.         goto pick_move;
  74.     }
  75.  
  76.     if(nix != omx || niy != omy) {
  77.         remove_monster(omx, omy);
  78.         place_monster(mtmp, nix, niy);
  79.         newsym(nix,niy);
  80.         if (mtmp->isshk && !in_his_shop && inhishop(mtmp))
  81.             check_special_room(FALSE);
  82.         if(ib) {
  83.             if (cansee(mtmp->mx,mtmp->my))
  84.                 pline("%s picks up %s.", Monnam(mtmp),
  85.                 distant_name(ib,doname));
  86.             freeobj(ib);
  87.             mpickobj(mtmp, ib);
  88.         }
  89.         return(1);
  90.     }
  91.     return(0);
  92. }
  93.  
  94. #endif /* OVLB */
  95.  
  96. #ifdef OVL0
  97.  
  98. char
  99. temple_occupied(array)
  100. register char *array;
  101. {
  102.     register char *ptr;
  103.  
  104.     for (ptr = array; *ptr; ptr++)
  105.         if (rooms[*ptr - ROOMOFFSET].rtype == TEMPLE)
  106.             return(*ptr);
  107.     return('\0');
  108. }
  109.  
  110. #endif /* OVL0 */
  111. #ifdef OVLB
  112.  
  113. static boolean
  114. histemple_at(priest, x, y)
  115. register struct monst *priest;
  116. register xchar x, y;
  117. {
  118.     return((boolean)((EPRI(priest)->shroom == *in_rooms(x, y, TEMPLE)) &&
  119.            on_level(&(EPRI(priest)->shrlevel), &u.uz)));
  120. }
  121.  
  122. /*
  123.  * pri_move: return 1: moved  0: didn't  -1: let m_move do it  -2: died
  124.  */
  125. int
  126. pri_move(priest)
  127. register struct monst *priest;
  128. {
  129.     register xchar gx,gy,omx,omy;
  130.     schar temple;
  131.     boolean avoid = TRUE;
  132.  
  133.     omx = priest->mx;
  134.     omy = priest->my;
  135.  
  136.     if(!histemple_at(priest, omx, omy)) return(-1);
  137.  
  138.     temple = EPRI(priest)->shroom;
  139.  
  140.     gx = EPRI(priest)->shrpos.x;
  141.     gy = EPRI(priest)->shrpos.y;
  142.  
  143.     gx += rn1(3,-1);    /* mill around the altar */
  144.     gy += rn1(3,-1);
  145.  
  146.     if(!priest->mpeaceful ||
  147.        (Conflict && !resist(priest, RING_CLASS, 0, 0))) {
  148.         if(monnear(priest, u.ux, u.uy)) {
  149.             if(Displaced)
  150.                 Your("displaced image doesn't fool %s!",
  151.                     mon_nam(priest));
  152.             (void) mattacku(priest);
  153.             return(0);
  154.         } else if(index(u.urooms, temple)) {
  155.             /* chase player if inside temple & can see him */
  156.             if(priest->mcansee && m_canseeu(priest)) {
  157.                 gx = u.ux;
  158.                 gy = u.uy;
  159.             }
  160.             avoid = FALSE;
  161.         }
  162.     } else if(Invis) avoid = FALSE;
  163.  
  164.     return(move_special(priest,FALSE,TRUE,FALSE,avoid,omx,omy,gx,gy));
  165. }
  166.  
  167. /* exclusively for mktemple() */
  168. void
  169. priestini(lvl, sroom, sx, sy, sanctum)
  170. d_level    *lvl;
  171. struct mkroom *sroom;
  172. int sx, sy;
  173. boolean sanctum;   /* is it the seat of the high priest? */
  174. {
  175.     register struct monst *priest;
  176.     register struct obj *otmp;
  177.     register int cnt;
  178.  
  179.     if(MON_AT(sx+1, sy))
  180.         rloc(m_at(sx+1, sy)); /* insurance */
  181.  
  182.     priest = (sanctum ? makemon(&mons[PM_HIGH_PRIEST], sx+1, sy)
  183.               : makemon(&mons[PM_ALIGNED_PRIEST], sx+1, sy));
  184.     if (priest) {
  185.         EPRI(priest)->shroom = (sroom - rooms) + ROOMOFFSET;
  186.         EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask);
  187.         EPRI(priest)->shrpos.x = sx;
  188.         EPRI(priest)->shrpos.y = sy;
  189.         assign_level(&(EPRI(priest)->shrlevel), lvl);
  190.         priest->mtrapseen = ~0;    /* traps are known */
  191.         priest->mpeaceful = 1;
  192.         priest->ispriest = 1;
  193.         priest->msleep = 0;
  194.         set_malign(priest); /* mpeaceful may have changed */
  195.  
  196.         /* now his/her goodies... */
  197.         (void) mongets(priest, CHAIN_MAIL);
  198.         (void) mongets(priest, SMALL_SHIELD);
  199. #ifdef MUSE
  200.         m_dowear(priest, TRUE);
  201. #endif
  202.         priest->mgold = (long)rn1(10,20);
  203.         if(sanctum && EPRI(priest)->shralign == A_NONE &&
  204.              on_level(&sanctum_level, &u.uz))
  205.             (void) mongets(priest, AMULET_OF_YENDOR);
  206.         /* Do NOT put the rest in m_initinv.    */
  207.         /* Priests created elsewhere than in a  */
  208.         /* temple should not carry these items, */
  209.         /* except for the mace.            */
  210.         cnt = rn1(2,3);
  211.         while(cnt) {
  212.             otmp = mkobj(SPBOOK_CLASS, FALSE);
  213.             if(otmp) mpickobj(priest, otmp);
  214.             cnt--;
  215.         }
  216.         if(p_coaligned(priest))
  217.             (void) mongets(priest, rn2(2) ? CLOAK_OF_PROTECTION
  218.                           : CLOAK_OF_MAGIC_RESISTANCE);
  219.         else {
  220.             if(!rn2(5))
  221.             otmp = mksobj(CLOAK_OF_MAGIC_RESISTANCE, TRUE, FALSE);
  222.             else otmp = mksobj(CLOAK_OF_PROTECTION, TRUE, FALSE);
  223.             if(otmp) {
  224.             if(!rn2(2)) curse(otmp);
  225.             mpickobj(priest, otmp);
  226.             }
  227.         }
  228.  
  229.         otmp = mksobj(MACE, FALSE, FALSE);
  230.         if(otmp) {
  231.             otmp->spe = rnd(3);
  232.             if(!rn2(2)) curse(otmp);
  233.             mpickobj(priest, otmp);
  234.         }
  235.     }
  236. }
  237.  
  238. /*
  239.  * Specially aligned monsters are named specially.
  240.  *    - aligned priests with ispriest and high priests have shrines
  241.  *        they retain ispriest and epri when polymorphed
  242.  *    - aligned priests without ispriest and Angels are roamers
  243.  *        they retain isminion and access epri as emin when polymorphed
  244.  *        (coaligned Angels are also created as minions, but they
  245.  *        use the same naming convention)
  246.  *    - minions do not have ispriest but have isminion and emin
  247.  */
  248. char *
  249. priestname(mon)
  250. register struct monst *mon;
  251. {
  252.     static NEARDATA char pname[PL_NSIZ];
  253.  
  254.     Strcpy(pname, "the ");
  255.     if (mon->minvis) Strcat(pname, "invisible ");
  256.     if (mon->ispriest || mon->data == &mons[PM_ALIGNED_PRIEST] ||
  257.                     mon->data == &mons[PM_ANGEL]) {
  258.         /* use epri */
  259.         if (mon->mtame && mon->data == &mons[PM_ANGEL])
  260.             Strcat(pname, "guardian ");
  261.         if (mon->data != &mons[PM_ALIGNED_PRIEST] &&
  262.                 mon->data != &mons[PM_HIGH_PRIEST]) {
  263.             Strcat(pname, mon->data->mname);
  264.             Strcat(pname, " ");
  265.         }
  266.         if (mon->data != &mons[PM_ANGEL]) {
  267.             if (!mon->ispriest && EPRI(mon)->renegade)
  268.                 Strcat(pname, "renegade ");
  269.             if (mon->data == &mons[PM_HIGH_PRIEST])
  270.                 Strcat(pname, "high ");
  271.             if (mon->female)
  272.                 Strcat(pname, "priestess ");
  273.             else
  274.                 Strcat(pname, "priest ");
  275.         }
  276.         Strcat(pname, "of ");
  277.         Strcat(pname, align_gname((int)EPRI(mon)->shralign));
  278.         return(pname);
  279.     }
  280.     /* use emin instead of epri */
  281.     Strcat(pname, mon->data->mname);
  282.     Strcat(pname, " of ");
  283.     Strcat(pname, align_gname(EMIN(mon)->min_align));
  284.     return(pname);
  285. }
  286.  
  287. boolean
  288. p_coaligned(priest)
  289. struct monst *priest;
  290. {
  291.     return((boolean)(u.ualign.type == ((int)EPRI(priest)->shralign)));
  292. }
  293.  
  294. static boolean
  295. has_shrine(pri)
  296. struct monst *pri;
  297. {
  298.     struct rm *lev;
  299.  
  300.     if(!pri)
  301.         return(FALSE);
  302.     lev = &levl[EPRI(pri)->shrpos.x][EPRI(pri)->shrpos.y];
  303.     if (!IS_ALTAR(lev->typ) || !(lev->altarmask & AM_SHRINE))
  304.         return(FALSE);
  305.     return((boolean)(EPRI(pri)->shralign == Amask2align(lev->altarmask & ~AM_SHRINE)));
  306. }
  307.  
  308. struct monst *
  309. findpriest(roomno)
  310. char roomno;
  311. {
  312.     register struct monst *mtmp;
  313.     extern struct monst *fdmon; /* from mon.c */
  314.  
  315.     for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  316.         if(mtmp->ispriest && (EPRI(mtmp)->shroom == roomno) &&
  317.            histemple_at(mtmp,mtmp->mx,mtmp->my))
  318.         return(mtmp);
  319.     for(mtmp = fdmon; mtmp; mtmp = mtmp->nmon)
  320.         if(mtmp->ispriest && (EPRI(mtmp)->shroom == roomno) &&
  321.            histemple_at(mtmp,mtmp->mx,mtmp->my))
  322.         return(mtmp);
  323.     return (struct monst *)0;
  324. }
  325.  
  326. /* called from check_special_room() when the player enters the temple room */
  327. void
  328. intemple(roomno)
  329. register int roomno;
  330. {
  331.     register struct monst *priest = findpriest((char)roomno);
  332.     boolean tended = (priest != (struct monst *)0);
  333.     boolean shrined = (tended && has_shrine(priest));
  334.     boolean sanctum = (tended && priest->data == &mons[PM_HIGH_PRIEST] &&
  335.                 (Is_sanctum(&u.uz) || In_endgame(&u.uz)));
  336.  
  337.     if(!temple_occupied(u.urooms0)) {
  338.         if(tended) {
  339.         pline("%s intones:",
  340.               (!Blind ? Monnam(priest) : "A nearby voice"));
  341.         if(sanctum && Is_sanctum(&u.uz)) {
  342.             if(priest->mpeaceful) {
  343.               verbalize("Infidel, you entered Moloch's Sanctum!");
  344.               verbalize("Be gone!");
  345.               priest->mpeaceful = 0;
  346.               set_malign(priest);
  347.             } else
  348.               verbalize("You desecrate this place by your presence!");
  349.         } else verbalize("Pilgrim, you enter a%s place!",
  350.                !shrined ? " desecrated" :
  351.                " sacred");
  352.         if(!sanctum) {
  353.             /* !tended -> !shrined */
  354.             if(!shrined || !p_coaligned(priest) ||
  355.                            u.ualign.record < -5)
  356.             You("have a%s forbidding feeling...",
  357.                 (!shrined) ? "" : " strange");
  358.             else You("experience a strange sense of peace.");
  359.         }
  360.         } else {
  361.         switch(rn2(3)) {
  362.           case 0: You("have an eerie feeling..."); break;
  363.           case 1: You("feel like you are being watched."); break;
  364.           default: pline("A shiver runs down your %s.",
  365.             body_part(SPINE)); break;
  366.         }
  367.         if(!rn2(5)) {
  368.             struct monst *mtmp;
  369.  
  370.             if(!(mtmp = makemon(&mons[PM_GHOST],u.ux,u.uy))) return;
  371.             pline("An enormous ghost appears next to you!");
  372.             mtmp->mpeaceful = 0;
  373.             set_malign(mtmp);
  374.             if(flags.verbose)
  375.             You("are frightened to death, and unable to move.");
  376.             nomul(-3);
  377.             nomovemsg = "You regain your composure.";
  378.            }
  379.        }
  380.        }
  381. }
  382.  
  383. void
  384. priest_talk(priest)
  385. register struct monst *priest;
  386. {
  387.     boolean coaligned = p_coaligned(priest);
  388.     boolean strayed = (u.ualign.record < 0);
  389.  
  390.     if(priest->mflee || (!priest->ispriest && coaligned && strayed)) {
  391.         pline("%s doesn't want anything to do with you!",
  392.                 Monnam(priest));
  393.         priest->mpeaceful = 0;
  394.         return;
  395.     }
  396.  
  397.     /* priests don't chat unless peaceful and in their own temple */
  398.     if(!histemple_at(priest,priest->mx,priest->my) ||
  399.          !priest->mpeaceful || !priest->mcanmove || priest->msleep) {
  400.         if(!priest->mcanmove || priest->msleep) {
  401.         pline("%s breaks out of %s reverie!",
  402.               Monnam(priest), his[pronoun_gender(priest)]);
  403.         priest->mfrozen = priest->msleep = 0;
  404.         priest->mcanmove = 1;
  405.         }
  406.         priest->mpeaceful = 0;
  407.         switch(rn2(3)) {
  408.         case 0:
  409.            verbalize("Thou wouldst have words, eh?  I'll give thee a word or two!");
  410.            break;
  411.         case 1:
  412.            verbalize("Talk?  Here is what I have to say!");
  413.            break;
  414.         default:
  415.            verbalize("Pilgrim, I would speak no longer with thee.");
  416.            break;
  417.         }
  418.         return;
  419.     }
  420.  
  421.     /* you desecrated the temple and now you want to chat? */
  422.     if(priest->mpeaceful && *in_rooms(priest->mx, priest->my, TEMPLE) &&
  423.           !has_shrine(priest)) {
  424.         verbalize("Begone!  Thou desecratest this holy place with thy presence.");
  425.         priest->mpeaceful = 0;
  426.         return;
  427.     }
  428.  
  429.     if(!u.ugold) {
  430.         if(coaligned && !strayed) {
  431.         if (priest->mgold > 0L) {
  432.             /* Note: two bits is actually 25 cents.  Hmm. */
  433.             pline("%s gives you %s for an ale.", Monnam(priest),
  434.             (priest->mgold == 1L) ? "one bit" : "two bits");
  435.             if (priest->mgold > 1L)
  436.             u.ugold = 2L;
  437.             else
  438.             u.ugold = 1L;
  439.             priest->mgold -= u.ugold;
  440.             flags.botl = 1;
  441.         } else
  442.             pline("%s preaches the virtues of poverty.", Monnam(priest));
  443.         exercise(A_WIS, TRUE);
  444.         } else
  445.         pline("%s is not interested.", Monnam(priest));
  446.         return;
  447.     } else {
  448.         long offer;
  449.  
  450.         pline("%s asks you for a contribution for the temple.",
  451.             Monnam(priest));
  452.         if((offer = bribe(priest)) == 0) {
  453.         verbalize("Thou shalt regret thine action!");
  454.         if(coaligned) u.ualign.record--;
  455.         } else if(offer < (u.ulevel * 200)) {
  456.         if(u.ugold > (offer * 2L)) verbalize("Cheapskate.");
  457.         else {
  458.             verbalize("I thank thee for thy contribution.");
  459.             /*  give player some token  */
  460.             exercise(A_WIS, TRUE);
  461.         }
  462.         } else if(offer < (u.ulevel * 400)) {
  463.         verbalize("Thou art indeed a pious individual.");
  464.         if(u.ugold < (offer * 2L)) {
  465.             if(coaligned && u.ualign.record < -5) u.ualign.record++;
  466.             verbalize("I bestow upon thee a blessing.");
  467.             Clairvoyant += rn1(500,500);
  468.         }
  469.         } else if(offer < (u.ulevel * 600) &&
  470.               u.ublessed < 20 &&
  471.               (u.ublessed < 9 || !rn2(u.ublessed))) {
  472.         verbalize("Thy devotion has been rewarded.");
  473.         if (!(Protection & INTRINSIC))  {
  474.             Protection |= FROMOUTSIDE;
  475.             if (!u.ublessed)  u.ublessed = rn1(3, 2);
  476.         } else u.ublessed++;
  477.         } else {
  478.         verbalize("Thy selfless generosity is deeply appreciated.");
  479.         if(u.ugold < (offer * 2L) && coaligned) {
  480.             if(strayed && (moves - u.ucleansed) > 5000L) {
  481.             u.ualign.record = 0; /* cleanse thee */
  482.             u.ucleansed = moves;
  483.             } else {
  484.             u.ualign.record += 2;
  485.             }
  486.         }
  487.         }
  488.     }
  489. }
  490.  
  491. struct monst *
  492. mk_roamer(ptr, alignment, x, y, peaceful)
  493. register struct permonst *ptr;
  494. aligntyp alignment;
  495. xchar x, y;
  496. boolean peaceful;
  497. {
  498.     register struct monst *roamer;
  499.     register boolean coaligned = (u.ualign.type == alignment);
  500.  
  501.     if (ptr != &mons[PM_ALIGNED_PRIEST] && ptr != &mons[PM_ANGEL])
  502.         return((struct monst *)0);
  503.     
  504.     if (MON_AT(x, y)) rloc(m_at(x, y));    /* insurance */
  505.  
  506.     if (!(roamer = makemon(ptr, x, y)))
  507.         return((struct monst *)0);
  508.  
  509.     EPRI(roamer)->shralign = alignment;
  510.     if (coaligned && !peaceful)
  511.         EPRI(roamer)->renegade = TRUE;
  512.     /* roamer->ispriest == FALSE naturally */
  513.     roamer->isminion = TRUE;    /* borrowing this bit */
  514.     roamer->mtrapseen = ~0;        /* traps are known */
  515.     roamer->mpeaceful = peaceful;
  516.     roamer->msleep = 0;
  517.     set_malign(roamer); /* peaceful may have changed */
  518.  
  519.     /* MORE TO COME */
  520.     return(roamer);
  521. }
  522.  
  523. void
  524. reset_hostility(roamer)
  525. register struct monst *roamer;
  526. {
  527.         if(!(roamer->isminion && (roamer->data == &mons[PM_ALIGNED_PRIEST] ||
  528.                   roamer->data == &mons[PM_ANGEL])))
  529.             return;
  530.  
  531.         if(EPRI(roamer)->shralign != u.ualign.type) {
  532.         roamer->mpeaceful = roamer->mtame = 0;
  533.         set_malign(roamer);
  534.     }
  535.     newsym(roamer->mx, roamer->my);
  536. }
  537.  
  538. boolean
  539. in_your_sanctuary(x, y)
  540. xchar x, y;
  541. {
  542.     register char roomno;
  543.     register struct monst *priest;
  544.  
  545.     if ((u.ualign.record < -5) || !(roomno = temple_occupied(u.urooms)) ||
  546.         (roomno != *in_rooms(x, y, TEMPLE)) ||
  547.         !(priest = findpriest(roomno)))
  548.         return(FALSE);
  549.     return((boolean)(has_shrine(priest) && p_coaligned(priest) && priest->mpeaceful));
  550. }
  551.  
  552. void
  553. ghod_hitsu(priest)     /* when attacking "priest" in his temple */
  554. struct monst *priest;
  555. {
  556.     int x, y, ax, ay, roomno = (int)temple_occupied(u.urooms);
  557.     struct mkroom *troom;
  558.  
  559.     if (!roomno || !has_shrine(priest))
  560.         return;
  561.  
  562.     ax = x = EPRI(priest)->shrpos.x;
  563.     ay = y = EPRI(priest)->shrpos.y;
  564.     troom = &rooms[roomno - ROOMOFFSET];
  565.  
  566.     if((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y)) {
  567.         if(IS_DOOR(levl[u.ux][u.uy].typ)) {
  568.  
  569.         if(u.ux == troom->lx - 1) {
  570.             x = troom->hx;
  571.             y = u.uy;
  572.         } else if(u.ux == troom->hx + 1) {
  573.             x = troom->lx;
  574.             y = u.uy;
  575.         } else if(u.uy == troom->ly - 1) {
  576.             x = u.ux;
  577.             y = troom->hy;
  578.         } else if(u.uy == troom->hy + 1) {
  579.             x = u.ux;
  580.             y = troom->ly;
  581.         }
  582.         } else {
  583.         switch(rn2(4)) {
  584.         case 0:  x = u.ux; y = troom->ly; break;
  585.         case 1:  x = u.ux; y = troom->hy; break;
  586.         case 2:  x = troom->lx; y = u.uy; break;
  587.         default: x = troom->hx; y = u.uy; break;
  588.         }
  589.         }
  590.         if(!linedup(u.ux, u.uy, x, y)) return;
  591.     }
  592.  
  593.     switch(rn2(3)) {
  594.     case 0:
  595.         pline("%s roars in anger:  \"Thou shalt suffer!\"",
  596.             a_gname_at(ax, ay));
  597.         break;
  598.     case 1:
  599.         pline("%s voice booms:  \"How darest thou harm my servant!\"",
  600.             s_suffix(a_gname_at(ax, ay)));
  601.         break;
  602.     default:
  603.         pline("%s roars:  \"Thou dost profane my shrine!\"",
  604.             a_gname_at(ax, ay));
  605.         break;
  606.     }
  607.  
  608.     buzz(-10-(AD_ELEC-1), 6, x, y, sgn(tbx), sgn(tby)); /* bolt of lightning */
  609.     exercise(A_WIS, FALSE);
  610. }
  611.  
  612. void
  613. angry_priest()
  614. {
  615.     register struct monst *priest;
  616.  
  617.     if ((priest = findpriest(temple_occupied(u.urooms))) != 0)
  618.         wakeup(priest);
  619. }
  620.  
  621. /*
  622.  * When saving bones, find priests that aren't on their shrine level,
  623.  * and remove them.   This avoids big problems when restoring bones.
  624.  */
  625. void
  626. clearpriests()
  627. {
  628.     register struct monst *mtmp, *mtmp2;
  629.  
  630.     for(mtmp = fmon; mtmp; mtmp = mtmp2) {
  631.     mtmp2 = mtmp->nmon;
  632.     if (mtmp->ispriest && !on_level(&(EPRI(mtmp)->shrlevel), &u.uz))
  633.         mongone(mtmp);
  634.     }
  635. }
  636.  
  637. /* munge priest-specific structure when restoring -dlc */
  638. void
  639. restpriest(mtmp, ghostly)
  640. register struct monst *mtmp;
  641. boolean ghostly;
  642. {
  643.     if(u.uz.dlevel) {
  644.     if (ghostly)
  645.         assign_level(&(EPRI(mtmp)->shrlevel), &u.uz);
  646.     }
  647. }
  648.  
  649. #endif /* OVLB */
  650.  
  651. /*priest.c*/
  652.